Skip to content

Conversation

@sigurd4
Copy link

@sigurd4 sigurd4 commented Oct 19, 2025

Happened to look through the source code and found what seems to be a logical error in the check in MapWindows::new. There's supposed to be a check to prevent too large arrays for non-zero-sized types, but it seems to be wrong. Isn't this supposed to be != instead of ==?

Feature iter_map_windows issue #87155

Happened to look through the source code and found what seems to be a logical error in the check in `MapWindows::new`. There's supposed to be a check to prevent too large arrays for non-zero-sized types, but it seems to be wrong. Isn't this supposed to be `!=` instead of `==`?
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 19, 2025

r? @joboet

rustbot has assigned @joboet.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    iter::adapters::map_windows::test_too_large_array_size

test result: FAILED. 2242 passed; 1 failed; 5 ignored; 0 measured; 0 filtered out; finished in 2.86s

error: test failed, to rerun pass `-p coretests --test coretests`
env -u RUSTC_WRAPPER CARGO_ENCODED_RUSTDOCFLAGS="-Csymbol-mangling-version=v0\u{1f}-Zrandomize-layout\u{1f}-Zunstable-options\u{1f}--check-cfg=cfg(bootstrap)\u{1f}-Dwarnings\u{1f}-Wrustdoc::invalid_codeblock_attributes\u{1f}--crate-version\u{1f}1.92.0-nightly\t(c8e65743b\t2025-10-19)" CARGO_ENCODED_RUSTFLAGS="-Csymbol-mangling-version=v0\u{1f}-Zrandomize-layout\u{1f}-Zunstable-options\u{1f}--check-cfg=cfg(bootstrap)\u{1f}-Zmacro-backtrace\u{1f}-Csplit-debuginfo=off\u{1f}-Clink-arg=-L/usr/lib/llvm-20/lib\u{1f}-Cllvm-args=-import-instr-limit=10\u{1f}-Clink-args=-Wl,-z,origin\u{1f}-Clink-args=-Wl,-rpath,$ORIGIN/../lib\u{1f}-Alinker-messages\u{1f}--cap-lints=allow\u{1f}--cfg\u{1f}randomized_layouts" RUSTC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/dist/rustc-clif" RUSTDOC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/dist/rustdoc-clif" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo" "test" "--manifest-path" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/sysroot_tests/Cargo.toml" "--target-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/sysroot_tests_target" "--locked" "--target" "aarch64-unknown-linux-gnu" "-p" "coretests" "-p" "alloctests" "--tests" "--" "-q" exited with status ExitStatus(unix_wait_status(25856))
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color always --release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/test.rs:3689:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3734:26

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:21:26
  local time: Sun Oct 19 21:29:15 UTC 2025
  network time: Sun, 19 Oct 2025 21:29:15 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

@sigurd4
Copy link
Author

sigurd4 commented Oct 20, 2025

I may have misunderstood the intention of that check, as to why it only performs the check for ZST. Looking at how the unit test for too large arrays start failing, i assume I've misunderstood.

@joboet
Copy link
Member

joboet commented Oct 20, 2025

For non-ZSTs, a [[T; N]; 2] can only exist as a type if [T; N * 2] can exist, otherwise the result is a monomorphisation error. But for ZSTs, there is no such guarantee, as the size in memory is always zero. Hence it's not always possible to obtain a [T; N * 2] from the [[T; N]; 2], but that is needed by MapWindows. In conclusion, == is the right comparison.

@joboet joboet closed this Oct 20, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants